package mall.kotlin.com.myapplication.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * USER: zjw
 * DATA: 2018/11/20 0020
 * TIME: 下午 2:31
 */
public class Proxyfactory {
    Object mtag;

    public Proxyfactory(Object mtag) {
        this.mtag = mtag;
    }

    public Object getproxyInstance(){
        return Proxy.newProxyInstance(mtag.getClass().getClassLoader(), mtag.getClass().getInterfaces(), new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                Object invoke = method.invoke(mtag, args);
                return invoke;
            }
        });
    }
}
